package common.util;

import tk.mybatis.mapper.entity.Example;

/**
 * Created with IntelliJ IDEA.
 *
 * @author ranhongmin--2018/1/19
 * Description:通用查询跳江
 */
@Deprecated
public class ExampleCreateCriteriaUtil<R extends Example> {
	private Example r;
	private Example.Criteria criteria = r.createCriteria();

	/**
	 * construct
	 *
	 * @param r Example
	 */
	public ExampleCreateCriteriaUtil(Example r) {
		this.r = r;
	}

	public Example createCriteria(String sortStr, String hidStr) {
		Example.OrderBy orderBy = r.orderBy(sortStr);
		orderBy.desc();
		criteria.andEqualTo(hidStr, "1");
		return r;
	}

	/**
	 * 排序
	 *
	 * @param sortStr 排序字段
	 * @return Example
	 */
	public Example createCriteriaSort(String sortStr) {
		Example.OrderBy orderBy = r.orderBy(sortStr);
		orderBy.desc();
		return r;
	}


	/**
	 * @param hidStr 隐藏字段
	 * @param state  状态 0:隐藏 1:显示
	 * @return Example
	 */
	public Example createCriteriaHide(String hidStr, String state) {
		criteria.andEqualTo(hidStr, state);
		return r;
	}

	/**
	 * @param isDelStr 是否删除字段
	 * @param state    状态 0:已删除 1:未删除
	 * @return Example
	 */
	public Example createCriteriaIsDel(String isDelStr, String state) {
		criteria.andEqualTo(isDelStr, "0");
		return r;
	}
}
